/*		Filename: 	session.h
 *		Author:		彭望
 *		Date:		2012-01-10
 *		Use:		定义每次上机对应的实体
 */

#ifndef SESSION_H
#define SESSION_H

#include "public.h"
#include "logger.h"
#include "net_manager.h"
#include "message.pb.h"
using boost::posix_time::ptime;
class CLogicalServer;

class CSession
{
	public:
		typedef boost::asio::ip::tcp::socket socket_t;
	public:
		CSession(const CLogicalServer& logicalServer);
		RetCode_t process(istream& req, ostream& res);

	private:
		//查询余额
		RetCode_t get_balance();
		//查询使用时长
		RetCode_t get_useDuration();
		//查询消费金额
		RetCode_t get_cost();
		//查询汇总信息
		RetCode_t get_all_info();
		//下机
		RetCode_t logoff();
		//上机
		RetCode_t login();

	private:
		//服务器对象引用
		const CLogicalServer& m_logicalServer;
		//上机时间
		ptime m_loginTime;
		//下机时间
		ptime m_logoutTime;

		Logger::Logger_t& logger;
		
};

typedef boost::shared_ptr<CSession> CSessionPtr;
#endif
